package com.lagou.utils;

import com.lagou.config.BoundSql;

import java.util.List;

/**
 * @author: jie.zhao
 * @create: 2021/02/02 14:50
 */
public class BoundSqlUtil {
    public static BoundSql getBoundSql(String sql) {
        ParameterMappingTokenHandler tokenHandler = new ParameterMappingTokenHandler();
        GenericTokenParser genericTokenParser = new GenericTokenParser("#{", "}", tokenHandler);
        String parseSql = genericTokenParser.parse(sql);
        List<ParameterMapping> parameterMappings = tokenHandler.getParameterMappings();
        BoundSql boundSql = new BoundSql(parseSql, parameterMappings);
        return boundSql;
    }
}
